//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.wsd.smartcarwasher.dao;

import com.wsd.smartcarwasher.domain.Machine;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.dao.DataAccessException;

import java.util.List;
import java.util.Map;

public interface MachineDao {

    List<Machine> getCouponMachines(Integer id);

    int addMachine(Machine machine) throws DataAccessException;

    int updateMachineStatus(int id, int status) throws DataAccessException;

    Machine queryMachineById(int id) throws DataAccessException;

    Machine queryMachineByName(String name) throws DataAccessException;

    List<Machine> queryMachines(@Param("filterCondition") Map<String, Object> filterCondition) throws DataAccessException;

    List<Machine> queryMachineByIds(@Param("idList") List<String> idList) throws DataAccessException;

//    List<Machine> queryMachineById(@Param("machineId") int  machineId) throws DataAccessException;

    List<Machine> queryMachineByNames(@Param("nameList") List<String> nameList) throws DataAccessException;

    int updateMachine(Machine machine) throws DataAccessException;

    List<Machine> queryAllMachine() throws DataAccessException;

    List<Machine> queryAllWorkingMachine() throws DataAccessException;

    int setMachinePartnerId(@Param("partnerId") int partnerId, @Param("nameList") List<String> nameList) throws DataAccessException;

    List<Machine> getMachinesByPartnerId(int partnerId) throws DataAccessException;

    int updateMachineWorkState(@Param("workState") int workState, @Param("machineId") int machineId) throws DataAccessException;

    int removeMachineOfPartner(int partnerId) throws DataAccessException;

    int changeMachineOnlineState(@Param("machineId") String machineId, @Param("online") int online) throws DataAccessException;

    List<Machine> queryUnRelatedMachines() throws DataAccessException;

    //查询附近定义公里的机器
    @Select("select * from machine m where (\n" +
            "acos(\n" +
            "sin((#{Lat}*3.1415)/180) * sin((m.latitude*3.1415)/180) + \n" +
            "cos((#{Lat}*3.1415)/180) * cos((latitude*3.1415)/180) * cos((#{Lng}*3.1415)/180 - (longitude*3.1415)/180)\n" +
            ")*6370.996\n" +
            ")<=#{around} and online=1 and status=1;")
    List<Machine> queryNearByMachine(@Param("Lng")String Lng, @Param("Lat")String Lat,@Param("around")String around) throws DataAccessException;
    @Select("select * from machine where storeId=#{storeId}")
    List<Machine> queryStoreMachine(Integer storeId);
    int setMachinePartnerIdById(@Param("partnerId") int partnerId, @Param("nameList") List<Machine> machines) throws DataAccessException;

    @Update("UPDATE machine set is_operate = #{is_operate} WHERE id = #{machineId} ")
    int updateMachineOperate(int is_operate,String machineId);

}
